<extend name="Public:base" />
<block name="btitle"><title>项目库</title></block>
<block name="bcontainer">
    <div class="page-wrapper" id="main">
        <div class="container">
            <div class="cart-list" id="divContainer">
                <volist name="projects" id="vo">
                    <a href="{:U('/Index/projects2')}" class="cart-item project-item">
                        <div class="row">
                            <div class="col-xs-6 display-ellipsis">
                                <strong class="project-job">{$vo.name}</strong>
                            </div>
                            <div class="col-xs-6 text-right display-ellipsis">
                                <span class="pj-money">&#165;{$vo.salary}</span>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-6 display-ellipsis">
                                {$vo.tname}
                            </div>
                            <div class="col-xs-6 text-right display-ellipsis">
                                <span class="label label-success">{$vo.moneyin|toTuoguanDesc}</span>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-xs-6 display-ellipsis">
                                招聘人数：{$vo.num}人
                            </div>
                            <div class="col-xs-6 text-right display-ellipsis">
                                剩余席位：{$vo['num']-$vo['datastate']}人
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-6 display-ellipsis">
                                <strong>创建者：</strong>{$vo.creater}
                            </div>
                            <div class="col-xs-6 text-right display-ellipsis">
                                <span class="text-danger">5 <i class="fa fa-heart"></i></span>
                            </div>
                        </div>
                    </a>
                </volist>
            </div>
            <br />
            <div class="load-more"><i class="fa fa-angle-double-down"></i>&nbsp;&nbsp;下拉加载更多</div>
            <br />
            <br />
            <br />
        </div>
    </div>
</block>
<block name="bfooterscript">
    <script type="text/x-kendo-template" id="tplCartItem">
        <a href="{:U('/Index/projects2')}" class="cart-item project-item">
            <div class="row">
                <div class="col-xs-6 display-ellipsis">
                    <strong class="project-job">#:name#</strong>
                </div>
                <div class="col-xs-6 text-right display-ellipsis">
                    <span class="pj-money">#:salary#</span>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6 display-ellipsis">
                    #:name#
                </div>
                <div class="col-xs-6 text-right display-ellipsis">
                    <span class="label label-success">#:moneyin==1?"已托管":"未托管"#</span>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-6 display-ellipsis">
                    招聘人数：#:num#人
                </div>
                <div class="col-xs-6 text-right display-ellipsis">
                    剩余席位：#:num-datastate#人
                </div>
            </div>
            <div class="row">
                <div class="col-xs-6 display-ellipsis">
                    <strong>创建者：</strong>#:creater#
                </div>
                <div class="col-xs-6 text-right display-ellipsis">
                    <span class="text-danger">#:favcount# <i class="fa fa-heart"></i></span>
                </div>
            </div>
        </a>
    </script>
    <script type="text/javascript" src="/Publicm/scripts/kendo.core.min.js"></script>
    <script type="text/javascript">
        var page = 2;
        var loading = false;
        var totalpage = 100;

        $(document).ready(function () {
          
            //$('#divContainer').load(server, { 'page': page }, function () { page++; $('.animation_image').hide(); });

            $(window).scroll(function () {

                if ($(window).scrollTop() + $(window).height() == $(document).height()) {
                    if (page <= totalpage && loading == false) {
                        loading = true;
                        $('.load-more').hide();
                        var server = "{:U('/Index/prjs_ajax', '', '')}-p-" + page;
                        $.get(server, {  }, function (data) {
                            if (data.projects && data.projects.length) {
                                var tpl = kendo.template($("#tplCartItem").html());
                                var html = kendo.render(tpl, data.projects);
                                $("#divContainer").append($(html).css("opacity", 0));
                                $("#divContainer .cart-item").animate({ opacity: 1 }, 500);
                            } else {
                                totalpage = page;
                            }
                            page++;
                            $('.load-more').show();
                            loading = false;

                        }, "json").fail(function (xhr, ajaxOptions, thrownError) {
                            alert(thrownError); //alert with HTTP error
                            $('.load-more').show();
                            loading = false;
                        });
                    }
                    if (page > totalpage) {
                        $('.load-more').text("已经没有数据了");
                    }
                }
            });
        });
    </script>

</block>